var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    num:1
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    this.setData({
      navH: app.globalData.navHeight,
    });

    wx.request({
      url: app.globalData.url + 'getUserNotificatonList',
      method: 'GET',
      data: {
        userId: wx.getStorageSync("userId"),
        type:0,
        page:1
      },
      success: function (res) {
        that.setData({
          information:res.data.data
        })
      }
    });
    
  },
  getMore: function () {
    var that = this;
    var num = that.data.num++;
    wx.request({
      url: app.globalData.url + 'getUserNotificatonList',
      method: 'GET',
      data: {
        userId: wx.getStorageSync("userId"),
        type: 0,
        page: num
      },
      success: function (res) {
        var information = that.data.information;
        for(var i=0;i<res.data.data.length;i++){
          information.push(res.data.data[i]);
        }
        that.setData({
          information: information
        })
      }
    });
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },
  navBack: function () {
    wx.navigateBack({

    })
  },
  bind:function(e){
    var that = this;
    var clickType = e.currentTarget.dataset.clicktype;
    if (clickType == 0) {

    } else if (clickType == 1) {
      var content = e.currentTarget.dataset.content.replace(/\s+/g, '');
      wx.navigateTo({
        url: '/pages/webView/webView?url=' + content,
      })
    } else if (clickType == 4) {
      wx.setStorageSync("deschtml", e.currentTarget.dataset.content);
      wx.navigateTo({
        url: '/pages/richText/richText' ,
      })
    } else  {
      var content = e.currentTarget.dataset.content.replace(/\s+/g, '');
      if (content == '/pages/activityPage/activityPage') {
        wx.switchTab({
          url: '/pages/activityPage/activityPage'
        });
      } else {
        wx.navigateTo({
          url: content,
        })
      }
    }
  },
})